package init

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

func mysqlConnectInit() {
	err := orm.RegisterDataBase("default",
		"mysql",
		fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s&loc=Local",
			beego.AppConfig.String("mysqluser"),
			beego.AppConfig.String("mysqlpass"),
			beego.AppConfig.String("mysqlurls"),
			beego.AppConfig.String("mysqlport"),
			beego.AppConfig.String("mysqldb"),
			beego.AppConfig.String("mysqlcharset"),
		))
	if err != nil {
		panic("数据库连接失败！")
	}
}
